jQuery(function() 
{ 
        $('#r_prno').select2(
    	{
    		placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
    		ajax: {
    				url: "globals_monitoring_SearchGlobal",dataType: 'json',type: 'POST',
    				data: function(term, page) 
    				{return {SearchName: term,page: page || 1}},
    				results: function(bond, page) 
    				{return {results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)}}
    		},
    		formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
    		formatSelection: function(bond){return bond.NAME},
    		initSelection: function(elem, cb){return elem}
        });
        $('#r_serial').select2(
    	{
    		placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
    		ajax: {
    				url: "globals_serial_SearchGlobal",dataType: 'json',type: 'POST',
    				data: function(term, page) 
    				{return {SearchName: term,page: page || 1}},
    				results: function(bond, page) 
    				{return {results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)}}
    		},
    		formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
    		formatSelection: function(bond){return bond.NAME},
    		initSelection: function(elem, cb){return elem}
        });
        $('#r_relatedname').select2(
    	{
    		placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
    		ajax: {
    				url: "globals_rel_SearchGlobal",dataType: 'json',type: 'POST',
    				data: function(term, page) 
    				{return {SearchName: term,page: page || 1}},
    				results: function(bond, page) 
    				{return {results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)}}
    		},
    		formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
    		formatSelection: function(bond){return bond.NAME},
    		initSelection: function(elem, cb){return elem}
        });
        var pJumlahI=$('#jumlahVendor').val();
        $('#r_name').select2(
    	{
    		placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
    		ajax: {
    				url: "globals_nik_SearchGlobal",dataType: 'json',type: 'POST',
    				data: function(term, page) 
    				{return {SearchName: term,page: page || 1}},
    				results: function(bond, page) 
    				{return {results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)}}
    		},
    		formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
    		formatSelection: function(bond){return bond.NAME},
    		initSelection: function(elem, cb){return elem}
        });
        var a=0;
        for(a=0;a<pJumlahI;a++){
            $('#r_venname'+a).select2(
        	{
        		placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
        		ajax: {
        				url: "globals_ven_Search",dataType: 'json',type: 'POST',
        				/*data:  
                            function(a,term, page) {
        				        return {
        				            nilai:a,SearchName: term,page: page || 1
                                }
                            },*/
                        data: 
                            function(term, page/*, a*/) {
        				        return {
        				            SearchName: term,page: page || 1//,nilai:a
                                }
                            }
                            ,    
        				results: function(bond, page){
        				            return {
        				                results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)
                                        }
                                }
        		},
        		formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
        		formatSelection: function(bond){return bond.NAME},
        		initSelection: function(elem, cb){return elem}
            });
        }
        
    $('#r_venname').select2(
        	{
        		placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
        		ajax: {
        				url: "globals_ven_Search",dataType: 'json',type: 'POST',
        				/*data:  
                            function(a,term, page) {
        				        return {
        				            nilai:a,SearchName: term,page: page || 1
                                }
                            },*/
                        data: 
                            function(term, page/*, a*/) {
        				        return {
        				            SearchName: term,page: page || 1//,nilai:a
                                }
                            }
                            ,    
        				results: function(bond, page){
        				            return {
        				                results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)
                                        }
                                }
        		},
        		formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
        		formatSelection: function(bond){return bond.NAME},
        		initSelection: function(elem, cb){return elem}
            });   
    /*
    var a=0;
    for(a=0;a<2;a++){
        $('#r_name'+a).select2(
    	{
    		placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
    		ajax: {
    				url: "globals_nik_Search",dataType: 'json',type: 'POST',
    				data: function(term, page) 
    				{return {SearchName: term,page: page || 1}},
    				results: function(bond, page) 
    				{return {results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)}}
    		},
    		formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
    		formatSelection: function(bond){return bond.NAME},
    		initSelection: function(elem, cb){return elem}
        })
    }
    */
})

jQuery(function() 
{ 
	var area_name = {area_name:$("#D_Area").val()};
	if(area_name == null)
	{
	
	}
	else
	{
		$('#D_Regional').select2(
		{
			minimumInputLength: 3,multiple: false,quietMillis: 0,id: function(bond){ return bond.AREA_ID;},
			ajax: {
					url: "getfilterRegional",dataType: 'json',type: 'POST',	data: function(term, page) 
					{return {getRegion: term,page: page || 1}},
					results: function(bond, page) 
					{return {results: bond.Show_Region, more: (bond.Show_Region && bond.Show_Region.length == 10 ? true: false)}}
			},
			formatResult: function(bond) {return '<div class="select2-user-result">' + bond.REGIONAL_NAME + '</div>'},
			formatSelection: function(bond){return bond.REGIONAL_NAME},
			initSelection: function(elem, cb){return elem}
		})	
	}
})
jQuery(function() 
{
    $("input[id^='G_Date']").datetimepicker(
	{
		scrollInput:false,closeOnDateSelect:true,datepicker:true,timepicker:false,format:'d/m/Y',minDate:'-1970/01/01',validateOnBlur:false,
		onGenerate:function( ct ){$(this).find('.xdsoft_date.xdsoft_weekend').addClass('xdsoft_enabled');}
        //onGenerate:function( ct ){$(this).find('.xdsoft_date.xdsoft_weekend').addClass('xdsoft_disabled');}
	});
});

jQuery(function()
{
    $("input[id^='G_Time']").datetimepicker(
	{
		scrollInput:false,closeOnDateSelect:true,datepicker:false,timepicker:true,format:'H:i',validateOnBlur:false,
		allowTimes:['07:00','07:30','08:30','09:00','09:30','10:00','10:30','11:00','12:00','12:30','13:00','13:30','14:00','14:30','15:00','15:30','16:00','16:30','17:00']
	});
});
